package cn.iocoder.yudao.module.member.address.vo;

import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.validation.groups.CreateGroup;
import cn.iocoder.yudao.framework.validation.groups.UpdateGroup;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Null;
import lombok.Data;

/**
 * 用户地址 Request VO
 */
@Data
public class AppAddressSaveReqVO {

    @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @NotNull(message = "编号不能为空", groups = {UpdateGroup.class})
    @Null(message = "编号必须为空", groups = {CreateGroup.class})
    private Long id;

    @Schema(description = "联系人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "羡民")
    @NotNull(message = "联系人名称不能为空", groups = {CreateGroup.class, UpdateGroup.class})
    private String name;

    @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15285116029")
    @NotNull(message = "手机号不能为空", groups = {CreateGroup.class, UpdateGroup.class})
    private String mobile;

    @SuppressWarnings("DeprecatedIsStillUsed")
    @Schema(description = "地区编号，使用`countyCode`代替", deprecated = true, example = "520102")
    @Deprecated
    private Integer areaId;

    @Schema(description = "区县编码", example = "520102")
    private String countyCode;

    @SuppressWarnings("unused")
    @AssertTrue(message = "区县编码不能为空")
    public boolean validateCountyCode() {
        return StrUtil.isNotBlank(countyCode) || (areaId != null && areaId > 0);
    }

    @Schema(description = "联系详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "花果园大街5号楼驰通集团公司")
    @NotNull(message = "联系详细地址不能为空")
    private String detailAddress;

    @Schema(description = "是否默认地址", example = "false")
    private Boolean defaultStatus;

}
